package cn.wxManage.goodsManage.controller;

import cn.common.common.model.ServerResponse;
import cn.wxManage.goodsManage.model.Goods;
import cn.wxManage.goodsManage.service.IGoodsManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Zhang on 2018/12/12.
 */
@RestController
@RequestMapping("/goods")
@Api(value="商品信息方法",description = "商品信息方法")
public class GoodsManageController {
    @Autowired
    IGoodsManageService iGoodsManageService;

    @ApiOperation(value="根据筛选条件可获取所有商品", notes="根据筛选条件可获取所有商品",
            produces = "application/json")
    @ApiImplicitParam(name = "Goods", value = "商品实体类",paramType ="body",dataType = "Goods")
    @PostMapping(value = "/getGoodsList")
    public ServerResponse<?> getGoodsList(@RequestBody Goods goods){
        return iGoodsManageService.getGoodsList(goods);
    }

    @ApiOperation(value="获取首页热门商品", notes="获取首页热门商品",produces = "application/json")
    @GetMapping(value = "/getHotGoodsList")
    public ServerResponse<?> getHotGoodsList(){
        return iGoodsManageService.getHotGoodsList();
    }

    @ApiOperation(value="搜索列表页商品", notes="搜索列表页商品",produces = "application/json")
    @ApiImplicitParam(name = "商品名称", value = "商品名称",paramType ="query",dataType = "String")
    @GetMapping(value = "/getSearchGoodsList")
    public ServerResponse<?> getSearchGoodsList(@RequestParam("name") String name){
        return iGoodsManageService.getSearchGoodsList(name);
    }

    @ApiOperation(value="获取指定商品详情页信息", notes="获取指定商品详情页信息",produces = "application/json")
    @ApiImplicitParam(name = "商品ID", value = "商品ID",paramType ="query",dataType = "Integer")
    @GetMapping(value = "/getGoodsInfo")
    public ServerResponse<?> getGoodsInfo(@RequestParam("id") Integer id){
        return iGoodsManageService.getGoodsInfo(id);
    }
}
